<?php 
/**
* 
*/
class Malbum extends CI_Model { 	
	public function __construct()
	{
		# code...
		 parent::__construct();
        $this->load->database();

	}
	public function getAlbumHot($limit) {
		$result=$this->db->query("SELECT album.idAlbum,album.idArtist,album.strImage,album.strNameAlbum,artist.strArtist,album.iRating
								FROM album
								LEFT JOIN artist ON CONVERT(album.idArtist USING utf8) =CONVERT(artist.idArtist USING utf8)
								ORDER BY album.iRating DESC
								LIMIT 0,$limit");
		return $result->result_array();

	}
	public function getAlbumInfo($id) {
		$result=$this->db->query("SELECT idAlbum,strNameAlbum,iRating,iYear,strReview,strImage FROM album WHERE idAlbum LIKE '$id'");
		return $result->result_array();
	}

	public function getSongAlbum($id) {
		$result=$this->db->query("SELECT album.idAlbum,album.strImage,album.strNameAlbum,artist.strArtist,album.iRating,album.iYear,song.idSong,song.strFileName,song.iTrack,song.strPath,album.idGenre,album.idTheme,theme.strTheme,genre.strGenre,song.strExtraArtist
			FROM album
			LEFT JOIN artist ON CONVERT(album.idArtist USING utf8) =CONVERT(artist.idArtist USING utf8)
			LEFT JOIN song ON CONVERT(album.idAlbum USING utf8) =CONVERT(song.idAlbum USING utf8)
			LEFT JOIN theme ON CONVERT(album.idTheme USING utf8) =CONVERT(theme.idTheme USING utf8)
			LEFT JOIN genre ON CONVERT(album.idGenre USING utf8) =CONVERT(genre.idGenre USING utf8)
			WHERE album.idAlbum lIKE '$id'
			ORDER BY song.iTrack  ASC");
		return $result->result_array();
	}
	public function updateRating($id,$value) {
			$this->db->query("UPDATE album 
								 SET iRating=$value
								 WHERE idAlbum='$id'");
	}


}
 ?>